const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const { UserInfo } = require('./src/userInfo');
const { Draft } = require('./src/draft')
const app = express();
const router = express.Router();

app.use(cors({
  origin: ['http://localhost:3000', 'http://viz.sparta.html5.qq.com'],
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  credentials: true,
}));
app.use('/', router);
app.use(bodyParser.json());
// app.all('*', function(req, res, next) {
//   // res.header("Access-Control-Allow-Origin", "*");
//   // res.header("Access-Control-Allow-Headers", "X-Requested-With,Content-Type");
//   // res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
//   next();
// });
// app.use(cors())


UserInfo(router);
Draft(router);

app.listen(8868);
console.log('server listening at port 8868');